home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Graphics⁄Sound / Fudd Source / Fudd ƒ / MSG Shell ƒ / msg about.c next >
Text File  |  1994-02-07  |  6KB  |  241 lines

  1. /**********************************************************************\
  2.  
  3. File:        msg about.c
  4.  
  5. Purpose:    This module handles the about boxes and that funky animation
  6.             in the "About MSG" about box.
  7.  
  8.  
  9. Fudd -=- convert text to Elmer Fudd talk
  10. Copyright ©1994, Mark Pilgrim
  11.  
  12. This program is free software; you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation; either version 2 of the License, or
  15. (at your option) any later version.
  16.  
  17. This program is distributed in the hope that it will be useful,
  18. but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. GNU General Public License for more details.
  21.  
  22. You should have received a copy of the GNU General Public License
  23. along with this program in a file named "GNU General Public License".
  24. If not, write to the Free Software Foundation, 675 Mass Ave,
  25. Cambridge, MA 02139, USA.
  26.  
  27. \**********************************************************************/
  28.  
  29. #include "msg about.h"
  30. #include "msg graphics.h"
  31. #include "msg prefs.h"
  32.  
  33. extern Point RawMouse : 0x82C;
  34.  
  35. PicHandle        gAboutColorPict;
  36. PicHandle        gAboutBWPict;
  37.  
  38. void DoTheMSGThing(void)
  39. {
  40.     /* assumes "About MSG" window (gTheWindow[kAboutMSG]) is the front window */
  41.     
  42.     Rect            sourceRect, destRect;
  43.     Rect            mainRect;
  44.     long            lr,tb;
  45.     int                l,t;
  46.     
  47.     mainRect=gMainScreenBounds;
  48.     mainRect.top-=MBarHeight;
  49.     if (PtInRect(RawMouse, &mainRect))
  50.     {
  51.         mainRect=gMainScreenBounds;
  52.         lr=RawMouse.h-mainRect.left;
  53.         lr*=81;
  54.         lr/=mainRect.right-mainRect.left;
  55.         tb=RawMouse.v-mainRect.top;
  56.         tb*=81;
  57.         tb/=mainRect.bottom-mainRect.top;
  58.         if (tb<0)
  59.             tb=0;
  60.         l=RawMouse.h-lr;
  61.         t=RawMouse.v-tb;
  62.         SetRect(&sourceRect, l, t, l+81, t+81);
  63.         SetRect(&destRect, 81, 81, 162, 162);
  64.         CopyBits(&(WMgrPort->portBits), &(gTheWindow[kAboutMSG]->portBits),
  65.             &sourceRect, &destRect, 0, 0L);
  66.     }
  67. }
  68.  
  69. void ShowInformation(void)
  70. {
  71.     OpenTheWindow(kAbout);
  72. }
  73.  
  74. void ShowSplashScreen(void)
  75. {
  76.     OpenTheWindow(kAboutMSG);
  77. }
  78.  
  79. void DrawTheCarpet(void)
  80. {
  81.     int                row;
  82.     Rect            sourceRect, destRect;
  83.     GrafPtr            curPort;
  84.     
  85.     GetPort(&curPort);
  86.     EraseRect(&(curPort->portRect));
  87.     
  88.     DrawCarpet(9,234,3);
  89.     SetRect(&sourceRect, 0, 216, 27, 243);
  90.     destRect=sourceRect;
  91.     OffsetRect(&destRect, 27, 0);
  92.     CopyBits(&(curPort->portBits), &(curPort->portBits),
  93.         &sourceRect, &destRect, 0, 0L);
  94.     OffsetRect(&destRect, -27, -27);
  95.     CopyBits(&(curPort->portBits), &(curPort->portBits),
  96.         &sourceRect, &destRect, 0, 0L);
  97.     OffsetRect(&destRect, 0, -27);
  98.     CopyBits(&(curPort->portBits), &(curPort->portBits),
  99.         &sourceRect, &destRect, 0, 0L);
  100.     OffsetRect(&destRect, 27, 0);
  101.     CopyBits(&(curPort->portBits), &(curPort->portBits),
  102.         &sourceRect, &destRect, 0, 0L);
  103.     SetRect(&sourceRect, 0, 162, 27, 243);
  104.     destRect=sourceRect;
  105.     OffsetRect(&destRect, 54, 0);
  106.     CopyBits(&(curPort->portBits), &(curPort->portBits),
  107.         &sourceRect, &destRect, 0, 0L);
  108.     SetRect(&sourceRect, 0, 162, 81, 243);
  109.     destRect=sourceRect;
  110.     OffsetRect(&destRect, 81, 0);
  111.     CopyBits(&(curPort->portBits), &(curPort->portBits),
  112.         &sourceRect, &destRect, 0, 0L);
  113.     OffsetRect(&destRect, -81, -81);
  114.     CopyBits(&(curPort->portBits), &(curPort->portBits),
  115.         &sourceRect, &destRect, 0, 0L);
  116.     OffsetRect(&destRect, 0, -81);
  117.     CopyBits(&(curPort->portBits), &(curPort->portBits),
  118.         &sourceRect, &destRect, 0, 0L);
  119.     OffsetRect(&destRect, 81, 0);
  120.     CopyBits(&(curPort->portBits), &(curPort->portBits),
  121.         &sourceRect, &destRect, 0, 0L);
  122.     SetRect(&sourceRect, 0, 0, 81, 243);
  123.     destRect=sourceRect;
  124.     OffsetRect(&destRect, 162, 0);
  125.     CopyBits(&(curPort->portBits), &(curPort->portBits),
  126.         &sourceRect, &destRect, 0, 0L);
  127.     
  128.     TextFont(geneva);
  129.     TextSize(9);
  130.     TextMode(srcXor);
  131.     row=92;
  132.     DrawTheString("\pMerriMac", &row);
  133.     DrawTheString("\pSoftware", &row);
  134.     DrawTheString("\pGroup ’94", &row);
  135.     DrawTheString("\p", &row);
  136.     DrawTheString("\pStill enhancing", &row);
  137.     DrawTheString("\pthe flavor of", &row);
  138.     DrawTheString("\pyour Macintosh.", &row);
  139. }
  140.  
  141. void DrawTheString(Str255 theString, int* theRow)
  142. {
  143.     MoveTo((gWindowWidth[kAboutMSG]-StringWidth(theString))/2, *theRow);
  144.     DrawString(theString);
  145.     *theRow+=11;
  146. }
  147.  
  148. void DrawCarpet(int x, int y, int len)
  149. {
  150.     Rect            box;
  151.     int                iter;
  152.  
  153.     x-=len*2;
  154.     y+=len*2;
  155.     for (iter=0; iter<8; iter++)
  156.     {
  157.         box.left=x-len;
  158.         box.right=x+2*len;
  159.         box.top=y-2*len;
  160.         box.bottom=y+len;
  161.         FillRect(&box, black);
  162.         if (len>1) DrawCarpet(x,y,len/3);
  163.         box.left=x;
  164.         box.right=x+len;
  165.         box.bottom=y;
  166.         box.top=y-len;
  167.         FillRect(&box, white);
  168.         switch (iter)
  169.         {
  170.             case 0:
  171.             case 1: x+=len*3; break;
  172.             case 2:
  173.             case 3: y-=len*3; break;
  174.             case 4:
  175.             case 5: x-=len*3; break;
  176.             case 6:
  177.             case 7: y+=len*3; break;
  178.         }
  179.     }
  180. }
  181.  
  182. void DrawTheAboutBox(Boolean isColor)
  183. {
  184.     int                row;
  185.     Handle            textHandle;
  186.     Str255            theLine;
  187.     unsigned long    pos;
  188.     unsigned long    theSize;
  189.     GrafPtr            curPort;
  190.     
  191.     GetPort(&curPort);
  192.     EraseRect(&(curPort->portRect));
  193.     DrawThePicture(isColor ? &gAboutColorPict : &gAboutBWPict, isColor ? kAboutColorID :
  194.         kAboutBWID, 73, 62);
  195.     
  196.     TextFont(geneva);
  197.     TextSize(9);
  198.     TextMode(srcCopy);
  199.     if (isColor)
  200.         ForeColor(blueColor);
  201.     row=16;
  202.     textHandle=GetResource('TEXT', 128);
  203.     if (textHandle==0L)
  204.         return;
  205.     if (*textHandle==0L)
  206.         LoadResource(textHandle);
  207.     if (*textHandle==0L)
  208.         return;
  209.     pos=0L;
  210.     theSize=SizeResource(textHandle);
  211.     do
  212.     {
  213.         GetTheNextLine(textHandle, theSize, &pos, theLine);
  214.         DrawTheAboutString(theLine, &row);
  215.     }
  216.     while (pos<theSize);
  217.     ReleaseResource(textHandle);
  218.     if (isColor)
  219.         ForeColor(redColor);
  220.     DrawTheAboutString(gMyName, &row);
  221.     DrawTheAboutString(gMyOrg, &row);
  222.     if (isColor)
  223.         ForeColor(blackColor);
  224. }
  225.  
  226. void GetTheNextLine(Handle textHandle, unsigned long theSize, unsigned long *pos, Str255 theLine)
  227. {
  228.     unsigned char    theChar;
  229.     
  230.     theLine[0]=0x00;
  231.     while ((*pos<theSize) && ((theChar=*((unsigned char*)(((long)(*textHandle))+((*pos)++))))!=0x0d))
  232.         theLine[++theLine[0]]=theChar;
  233. }
  234.  
  235. void DrawTheAboutString(Str255 theString, int *theRow)
  236. {
  237.     MoveTo(90-StringWidth(theString)/2, *theRow);
  238.     DrawString(theString);
  239.     *theRow+=12;
  240. }
  241.